<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>CruiseControl.NET : Multiple Projects</title>
	    <link rel="stylesheet" href="styles/site.css" type="text/css" />
        <META http-equiv="Content-Type" content="text/html; charset=UTF-8">	    
    </head>

    <body>
	    <table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
		    <tr>
			    <td valign="top" class="pagebody">
				    <div class="pageheader">
					    <span class="pagetitle">
                            CruiseControl.NET : Multiple Projects
                                                    </span>
				    </div>
				    <div class="pagesubheading">
					    This page last changed on Mar 20, 2009 by <font color="#0050B2">williams</font>.
				    </div>

				    <p>The CruiseControl.NET server can be configured to manage the integration requirements for several projects concurrently.  To do this, simply include the configuration for the different projects consecutively in the ccnet.config file.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml"><span class="code-tag">&lt;cruisecontrol&gt;</span>
     <span class="code-tag">&lt;project name=<span class="code-quote">"project1"</span>&gt;</span>
          ...
     <span class="code-tag">&lt;/project&gt;</span>
     <span class="code-tag">&lt;project name=<span class="code-quote">"project2"</span>&gt;</span>
          ...
     <span class="code-tag">&lt;/project&gt;</span>
<span class="code-tag">&lt;/cruisecontrol&gt;</span></pre>
</div></div>
<p>If you use the default values for Project <a href="Project Configuration Block.html#ProjectConfigurationBlock-workingDirectory">working directories</a>, <a href="Project Configuration Block.html#ProjectConfigurationBlock-artifactDirectory">artifact directories</a>, <a href="State Manager Blocks.html" title="State Manager Blocks">State Managers</a> and <a href="Xml Log Publisher.html" title="Xml Log Publisher">Xml Log Publishers</a>, this should work for you straightaway, but if not, note the following conditions:</p>
<ul>
	<li>Each project needs its own state file (see <a href="State Manager Blocks.html" title="State Manager Blocks">State Manager Blocks</a>)</li>
	<li>Each project must save build logs to a separate directory (see <a href="Xml Log Publisher.html" title="Xml Log Publisher">Xml Log Publisher</a>)</li>
	<li>Each project must have a separated build working directory (since builds are performed in parallel)</li>
	<li>Each project must have a trigger that specifies what will cause a build to occur (see <a href="Trigger Blocks.html" title="Trigger Blocks">Trigger Blocks</a>)</li>
</ul>


<h3><a name="MultipleProjects-ReducingConfigurationDuplication"></a>Reducing Configuration Duplication</h3>

<p>From CCNet 1.4 onwards, there is a Configuration PreProcessor, which allows to use variables and the like inside the ccnet config file. Look at the <a href="Configuration Preprocessor.html" title="Configuration Preprocessor">Pre Processor</a>for more information about this.</p>


<p>Before CCNet 1.4, the following technique is a solution.<br/>
As you add more projects to your <b>ccnet.config</b> file, you may end up with considerable duplication across configuration elements.  This can make it a hassle to maintain your projects as you have to update the same settings in many places.</p>

<p>You can achieve some degree of reuse by using DTD entities.  The example below demonstrates how you can create an entity to represent the cvs source control block so that it can be shared across two projects:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">&lt;!DOCTYPE cruisecontrol [
	<span class="code-tag">&lt;!ENTITY sc "&lt;sourcecontrol type='cvs'&gt;</span>
		<span class="code-tag">&lt;executable&gt;</span>c:\cvs\cvs.exe<span class="code-tag">&lt;/executable&gt;</span>
	<span class="code-tag">&lt;/sourcecontrol&gt;</span>"&gt;
]&gt;
<span class="code-tag">&lt;cruisecontrol&gt;</span>
	<span class="code-tag">&lt;project name=<span class="code-quote">"project1"</span>&gt;</span>
		&amp;sc;
	<span class="code-tag">&lt;/project&gt;</span>
	<span class="code-tag">&lt;project name=<span class="code-quote">"project2"</span>&gt;</span>
		&amp;sc;
	<span class="code-tag">&lt;/project&gt;</span>
<span class="code-tag">&lt;/cruisecontrol&gt;</span></pre>
</div></div>

<h3><a name="MultipleProjects-Splittingtheccnet.configfile"></a>Splitting the ccnet.config file</h3>

<p>You can also use DTD entity notation to split your ccnet.config file into multiple smaller xml files.  This can help you reduce duplication and can simplify the maintenance of certain configuration elements.  The following example demonstrates how the configuration for two CCNet project <b>project1</b> and <b>project2</b> can be read in from separate files.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">&lt;!DOCTYPE cruisecontrol [
	<span class="code-tag">&lt;!ENTITY project1 SYSTEM <span class="code-quote">"file:project1.xml"</span>&gt;</span>
	<span class="code-tag">&lt;!ENTITY project2 SYSTEM <span class="code-quote">"file:project2.xml"</span>&gt;</span>
]&gt;
<span class="code-tag">&lt;cruisecontrol&gt;</span>
  &amp;project1;
  &amp;project2;
<span class="code-tag">&lt;/cruisecontrol&gt;</span></pre>
</div></div>
<p>The same approach should work at any level in the <b>ccnet.config</b> file.  For example, email users and aliases can be managed in an external file:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">&lt;!DOCTYPE cruisecontrol [
	<span class="code-tag">&lt;!ENTITY email SYSTEM <span class="code-quote">"file:email.xml"</span>&gt;</span>
]&gt;
<span class="code-tag">&lt;cruisecontrol&gt;</span>
	<span class="code-tag">&lt;project name=<span class="code-quote">"project1"</span>&gt;</span>
		<span class="code-tag">&lt;publishers&gt;</span>
			&amp;email;
			<span class="code-tag">&lt;xmllogger /&gt;</span>
		<span class="code-tag">&lt;/publishers&gt;</span>
	<span class="code-tag">&lt;/project&gt;</span>
<span class="code-tag">&lt;/cruisecontrol&gt;</span></pre>
</div></div>
<p>One limitation of this approach is that these external files will not be monitored by the CCNet server.  Hence, CCNet will not automatically reload the configuration when these files change.  The <b>ccnet.config</b> file will need to be touched for these files to be reloaded.</p>

				    
                    			    </td>
		    </tr>
	    </table>
	    <table border="0" cellpadding="0" cellspacing="0" width="100%">
			<tr>
				<td height="12" background="http://confluence.public.thoughtworks.org//images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
			</tr>
		    <tr>
			    <td align="center"><font color="grey">Document generated by Confluence on Sep 29, 2009 20:59</font></td>
		    </tr>
	    </table>
    </body>
</html>